<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }

        
        
        
        div{
            margin-top: 60px;
            position: relative;
            width: 500px;
            height: auto;
            background-color: aqua;
        }
        div .jz1{
           
            width: 150px;
            height: auto;
            background-color:pink;
            margin:auto;

        }
        div .jz2{
            width: 100px;
            height: auto;
            background-color:red;
            position: relative; 
            left: 200px;
        }
        .jz3{
            background-color: yellow;
        }
        .mediate3{

            text-align: center;
        }
        .mediate4{
           width: 500px;
           height: 50px;
           position: relative;
        }
        .mediate4 p{
            width: 50px;
            height: 50px;
            background-color: blueviolet;
            position: absolute;
            left: 50%;
            margin-left: -25px;
        }




    </style>

</head>
<body>
    <div class="mediate1">
        <p class="jz1">居中方法1 设置盒子margin=auto</p>
    </div>
    <div class="mediate2">
        <p class="jz2">居中方法2 相对定位</p>
    </div>
    <div class="mediate3">
        <p class="jz3">text-align居中3</p>
    </div>
    <div class="mediate4">
        <p>居中4 绝对定位</p>
    </div>
</body>
</html>